package com.leyou.cart.listener;

import com.leyou.cart.service.CartService;
import com.leyou.common.constants.MQConstants;
import org.springframework.amqp.core.ExchangeTypes;
import org.springframework.amqp.rabbit.annotation.Exchange;
import org.springframework.amqp.rabbit.annotation.Queue;
import org.springframework.amqp.rabbit.annotation.QueueBinding;
import org.springframework.amqp.rabbit.annotation.RabbitListener;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import java.util.HashMap;
import java.util.List;

@Component
public class CartListener {

    @Autowired
    private CartService cartService;
    @RabbitListener(bindings = @QueueBinding(value = @Queue(value = MQConstants.Queue.ORDER_HAVE_QUEUE,declare = "true"),exchange =@Exchange(value = MQConstants.Exchange.ORDER_EXCHANGE_NAME,type = ExchangeTypes.TOPIC),key = MQConstants.RoutingKey.ORDER_KEY))
    public void deleteCart(HashMap<Long, List<Long>> carts){
        cartService.deleteCart(carts);
    }
}
